import request from '@/config/axios'


// 科室采购申请单 VO
export interface DepPurchaseVO {
  id: number // 编号
  warehouseId: number // 仓库编号
  deptId: string // 部门id
  orderId: string // 科室采购单编号
  integrateId: string // 整合单编号
  remark: string // 备注
  status: number // 状态
  processInstanceId: string // 流程实例的编号
  depPurchaseItems: any
  creatorName: string // 创建人
}

// 科室采购申请单 API
export const DepPurchaseApi = {
  // 查询科室采购申请单分页
  getDepPurchasePage: async (params: any) => {
    return await request.get({ url: `/erp/dep-purchase/page`, params })
  },
  // 查询科室采购申请单 工作流待办数据
  getWorkflowPage: async (params: any) => {
    return await request.get({ url: `/erp/dep-purchase/workflowPage`, params })
  },

  // 查询科室采购申请单详情
  getDepPurchase: async (id: number) => {
    return await request.get({ url: `/erp/dep-purchase/get?id=` + id })
  },

  // 新增科室采购申请单
  createDepPurchase: async (data: DepPurchaseVO) => {
    return await request.post({ url: `/erp/dep-purchase/create`, data })
  },
  // 分发方法
  fenfa: async (data: DepPurchaseVO) => {
    return await request.post({ url: `/erp/dep-purchase/fenfacreate`, data })
  },
  // 修改科室采购申请单
  updateDepPurchase: async (data: DepPurchaseVO) => {
    return await request.put({ url: `/erp/dep-purchase/update`, data })
  },
  updateDepPurchaseStatus: async (integraId: String) => {
    return await request.put({ url: `/erp/dep-purchase/updatestatus?integraId=`+integraId })
  },

  // 删除科室采购申请单
  deleteDepPurchase: async (id: number) => {
    return await request.delete({ url: `/erp/dep-purchase/delete?id=` + id })
  },

  // 导出科室采购申请单 Excel
  exportDepPurchase: async (params) => {
    return await request.download({ url: `/erp/dep-purchase/export-excel`, params })
  },
  // 根据整合单编号 修改科室采购申请单状态  static 6 
  updateDepPurchaseStatusByIntegraId: async (integraId,status) => {
    return await request.put({ url: `/erp/dep-purchase/updateDepPurchaseStatusByIntegraId?integraId=`+integraId+`&status=`+status })
  },

// ==================== 子表（科室采购申请项） ====================

  // 获得科室采购申请项列表
  getDepPurchaseItemListByOrderId: async (orderId) => {
    return await request.get({ url: `/erp/dep-purchase/dep-purchase-item/list-by-order-id?orderId=` + orderId })
  },
  // 获得ERP 科室采购申请项列表
  getnewDepPurchaseItemListByOrderId: async (orderId) => {
    return await request.get({ url: `/erp/dep-purchase/dep-purchase-item/newlist-by-order-id?orderId=` + orderId })
  },



    // 获得科室采购申请项列表
    getDepPurchaseItemList: async (params: any) => {
      return await request.get({ url: `/erp/dep-purchase/getDepPurchaseItemList`, params})
    },

      // 送审科室采购申请单
  submitPurchase: async (data: DepPurchaseVO) => {
    return await request.put({ url: `/erp/dep-purchase/submit`, data })
  },
}
